<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org/1999/xheml">
<head>
    <meta charset="UTF-8" content="text/html; charset=UTF-8">
    <title>Title</title>
    <script src="../static/jquery-1.11.3.min.js"></script>
</head>
<body>
<center>
    <h1>查询页面</h1>
    <a href="/addPage">新增</a>
    <table border="1">
        <tr>
            <th>编号</th>
            <th>姓名</th>
            <th>性别</th>
            <th>工作</th>
            <th>操作</th>
        </tr>
        <tr th:each="user:${users}">
            <td th:text="${user.id}"></td>
            <td th:text="${user.name}"></td>
            <td th:if="${user.sex==1}">男</td>
            <td th:if="${user.sex==2}">女</td>
            <td th:text="${user.work}"></td>
            <td>
                <a th:href="'javascript:del('+${user.id}+')'">删除</a>
                <a th:href="@{toUpdatePage/{userId}(userId=${user.id})}">修改</a>
            </td>
        </tr>
    </table>
</center>
<form id="formId" METHOD="post">
    <input type="hidden" name="_method" th:value="DELETE"/>
</form>
<script>
    function del(id){
        $("#formId").prop("action","/delete/"+id);
        $("#formId").submit();
    }
</script>
</body>
</html>